<!DOCTYPE html>
<html class="no-js" lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>后台管理系统</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- favicon
		============================================ -->
    <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
    <!-- Google Fonts
		============================================ -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700,900" rel="stylesheet">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/bootstrap.min.css">

    <!-- Lobibox CSS
        ============================================ -->
    <link rel="stylesheet" href="css/notifications/Lobibox.min.css">

    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/font-awesome.min.css">


    <!-- DatetimePicker CSS
        ============================================ -->
    <link rel="stylesheet" href="css/datetimepicker/bootstrap-datetimepicker.min.css">

    <!-- owl.carousel CSS
		============================================ -->
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/owl.theme.css">
    <link rel="stylesheet" href="css/owl.transitions.css">
    <!-- animate CSS
		============================================ -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- normalize CSS
		============================================ -->
    <link rel="stylesheet" href="css/normalize.css">
    <!-- meanmenu icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/meanmenu.min.css">
    <!-- main CSS
		============================================ -->
    <link rel="stylesheet" href="css/main.css">
    <!-- educate icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/educate-custon-icon.css">
    <!-- morrisjs CSS
		============================================ -->
    <link rel="stylesheet" href="css/morrisjs/morris.css">
    <!-- mCustomScrollbar CSS
		============================================ -->
    <link rel="stylesheet" href="css/scrollbar/jquery.mCustomScrollbar.min.css">
    <!-- metisMenu CSS
		============================================ -->
    <link rel="stylesheet" href="css/metisMenu/metisMenu.min.css">
    <link rel="stylesheet" href="css/metisMenu/metisMenu-vertical.css">
    <!-- calendar CSS
		============================================ -->
    <link rel="stylesheet" href="css/calendar/fullcalendar.min.css">
    <link rel="stylesheet" href="css/calendar/fullcalendar.print.min.css">

    <!-- form CSS
		============================================ -->
    <link rel="stylesheet" href="css/form/all-type-forms.css">

    <!-- style CSS
		============================================ -->
    <link rel="stylesheet" href="css/style.css">
    <!-- responsive CSS
		============================================ -->
    <link rel="stylesheet" href="css/responsive.css">
    <link rel="stylesheet" href="customcss/ul_style.css">

    <!-- modernizr JS
		============================================ -->
    <script src="admin/js/vendor/modernizr-2.8.3.min.js"></script>
    <style>
        .pagination {
            margin-top: 0;
            margin-bottom: 0;
        }

        .smallImage {
            width: 70px;
            border: 2px solid white;
        }

        .smallImage:hover {
            border: 2px solid black;
        }

        .table th, .table td {
            text-align: center;
            vertical-align: middle !important;
        }

    </style>
</head>

<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
    your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Start Left menu area -->
<div class="left-sidebar-pro">
    <nav id="sidebar" class="">
        <div class="sidebar-header">
            <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
            <strong><a href="index.html"><img src="img/logo/logosn.png" alt=""/></a></strong>
        </div>
        <div class="left-custom-menu-adp-wrap comment-scrollbar">
            <nav class="sidebar-nav left-sidebar-menu-pro">
                <ul class="metismenu" id="menu1">
                    <li class="active">
                        <a class="has-arrow" href="index.html">
                            <span class="fa fa-id-card"></span>
                            <span class="mini-click-non">用户信息</span>
                        </a>
                        <ul class="submenu-angle" aria-expanded="true">
                            <li><a href="index.html"><span class="mini-sub-pro">用户列表</span></a></li>
                            <li><a href="goodsManager.html"><span class="mini-sub-pro">商品列表</span></a></li>
                            <li><a href="order.html"><span class="mini-sub-pro">订单管理</span></a></li>
                            <li><a href="classify.html"><span class="mini-sub-pro">类目管理</span></a></li>
                            <li><a href="sc.html"><span class="mini-sub-pro">客户服务</span></a></li>
                        </ul>
                    </li>
                    <li>
                        <a title="Landing Page" href="adminUser.html" aria-expanded="false"><span
                                class="fa fa-user-circle-o" aria-hidden="true"></span> <span
                                class="mini-click-non">系统用户</span></a>
                    </li>
                </ul>
            </nav>
        </div>
    </nav>
</div>
<!-- End Left menu area -->
<!-- Start Welcome area -->
<div class="all-content-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="logo-pro">
                    <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
                </div>
            </div>
        </div>
    </div>
    <div class="header-advance-area">
        <div class="header-top-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="header-top-wraper">
                            <div class="row">
                                <div class="col-lg-1 col-md-0 col-sm-1 col-xs-12">
                                    <div class="menu-switcher-pro">
                                        <button type="button" id="sidebarCollapse"
                                                class="btn bar-button-pro header-drl-controller-btn btn-info navbar-btn">
                                            <i class="fa fa-bars"></i>
                                        </button>
                                    </div>
                                </div>

                                <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 col-lg-offset-6 col-md-offse-7 col-sm-offse-6 col-xs-offse-12">
                                    <div class="header-right-info">
                                        <ul class="nav navbar-nav mai-top-nav header-right-menu">
                                            <li class="nav-item">
                                                <div class="dropdown" id="notifyMenu">
                                                    <button type="button" class="btn btn-danger dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">
                                                        <i class="fa fa-bell" aria-hidden="true"></i>
                                                        <span class="badge" id="unreadNotify">0</span>
                                                        <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu"  aria-labelledby="dropdownMenu1" v-if="notifyData.length>0">
                                                        <!--消息列表-->
                                                        <li  v-for="notify in notifyData"  >
                                                            <a href="javascript:void(0)" v-on:click="fn($event)" :value="notify.path" :nid="notify.nid">
                                                                <div class="notification-content">
                                                                    <span class="bg-info" >{{notify.updateTime}}</span>
                                                                    <h5 style="margin-top: 10px">{{notify.title}}</h5>
                                                                    <p>点击查看详细信息</p>
                                                                </div>
                                                            </a>
                                                        </li>
                                                    </ul>
                                                    <ul class="dropdown-menu"  id="" aria-labelledby="dropdownMenu1" v-else>
                                                        <li>
                                                            <span style="font-size: 10px;color: darkgrey">暂无新的通知</span>
                                                        </li>
                                                        <li>
                                                            <a href="notification.html">查看所有通知</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </li>
                                            <li class="nav-item">
                                                <a href="#" data-toggle="dropdown" role="button" aria-expanded="false"
                                                   class="nav-link dropdown-toggle">
                                                    <img id="headImgs" src="img/product/pro4.jpg" alt=""/>
                                                    <span id="headName" class="admin-name"></span>
                                                    <i class="fa fa-angle-down edu-icon edu-down-arrow"></i>
                                                </a>
                                                <ul role="menu"
                                                    class="dropdown-header-top author-log dropdown-menu animated zoomIn">

                                                    <li><a onclick="logOut()"><span
                                                            class="edu-icon edu-locked author-log-ic"
                                                            style="cursor:pointer"></span>登出</a>
                                                    </li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--查看高清图-->
        <div class="modal" id="showBigImg" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button onclick="destoryShowBigImg()" class="close">
                            <span>&times;</span>
                        </button>
                        <h3 class="modal-title">高清图</h3>
                    </div>
                    <div class="modal-body" style="text-align: center">
                        <img class="bigImg" id="bigImg">
                    </div>
                </div>
            </div>
        </div>
        <div class="container-fluid" style="padding: 20px 15px 0 15px;">
            <div style="background-color: #ffffff; border-radius: 3px; padding: 12px;">

                <table id="goodsDataTable" class="table table-bordered table-striped"></table>

                <div id="goodsTableToolbar">
                    <button class="btn btn-success" onclick="showAddGoodsModal(1)">添加</button>
                </div>

                <div class="modal" id="addGoodsModal" data-backdrop="static">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button onclick="destoryAddGoodsModal()" class="close">
                                    <span>&times;</span>
                                </button>
                                <h3 class="modal-title">添加/编辑商品</h3>
                            </div>
                            <div class="modal-body">
                                <form>
                                    <input type="hidden" id="imageServerPath">
                                    <div class="form-group">
                                        <label for="title">标题</label>
                                        <input class="form-control" autocomplete="off" id="title">
                                    </div>

                                    <div class="form-group">
                                        <label for="enGoodsId">商品编号</label>
                                        <input class="form-control" autocomplete="off" id="enGoodsId">
                                    </div>
                                    <div class="form-group">
                                        <label for="items">种类</label>
                                        <select class="form-control" id="items">
<!--                                            <option value="1" selected>手机</option>-->
<!--                                            <option value="2">电脑</option>-->
<!--                                            <option value="3">鞋子</option>-->
<!--                                            <option value="6">背包</option>-->
<!--                                            <option value="7">图书</option>-->
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label>展示图<span style="color: red;">(在选择展示图之前必须选种类)</span></label>
                                        <div style="margin-bottom: 6px;">
                                            <img src="../images/default.png" width="158px" id="preDisplayImage"
                                                 height="180px">
                                        </div>
                                        <div class="file-upload-inner file-upload-inner-right ts-forms">
                                            <div class="input append-small-btn">
                                                <div class="file-button">
                                                    Browse
                                                    <input id="displayImage" autocomplete="off"
                                                           onchange="uploadDispalyImage(this)" type="file">
                                                </div>
                                                <input type="text" autocomplete="off" id="append-small-btn"
                                                       placeholder="no file selected">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="price">价格</label>
                                        <input class="form-control" autocomplete="off" id="price">
                                    </div>
                                    <div class="form-group">
                                        <label for="stock">库存</label>
                                        <input class="form-control" autocomplete="off" id="stock">
                                    </div>
                                    <input type="hidden" value="add" id="selectAddorEdit">
                                    <input type="hidden" id="goodsId">
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button onclick="destoryAddGoodsModal()" class="btn btn-danger">取消</button>
                                <button class="btn btn-success" onclick="addGoods()">确认</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- jquery
============================================ -->
<script src="js/vendor/jquery-1.12.4.min.js"></script>
<!-- bootstrap JS
============================================ -->
<script src="js/bootstrap.min.js"></script>
<!-- wow JS  动画效果js
============================================ -->
<script src="js/wow.min.js"></script>
<!-- price-slider JS
============================================ -->
<script src="js/jquery-price-slider.js"></script>
<!-- meanmenu JS
============================================ -->
<script src="js/jquery.meanmenu.js"></script>
<!-- owl.carousel JS
============================================ -->
<script src="js/owl.carousel.min.js"></script>
<!-- sticky JS
============================================ -->
<script src="js/jquery.sticky.js"></script>
<!-- scrollUp JS
============================================ -->
<script src="js/jquery.scrollUp.min.js"></script>
<!-- counterup JS
============================================ -->
<script src="js/counterup/jquery.counterup.min.js"></script>
<script src="js/counterup/waypoints.min.js"></script>
<script src="js/counterup/counterup-active.js"></script>
<!-- mCustomScrollbar JS
============================================ -->
<script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="js/scrollbar/mCustomScrollbar-active.js"></script>
<!-- metisMenu JS
============================================ -->
<script src="js/metisMenu/metisMenu.min.js"></script>
<script src="js/metisMenu/metisMenu-active.js"></script>


<script src="js/sparkline/jquery.sparkline.min.js"></script>
<script src="js/sparkline/jquery.charts-sparkline.js"></script>
<script src="js/sparkline/sparkline-active.js"></script>
<!-- calendar JS
============================================ -->
<script src="js/calendar/moment.min.js"></script>

<script src="js/calendar/fullcalendar.min.js"></script>
<script src="js/calendar/fullcalendar-active.js"></script>
<!-- plugins JS
============================================ -->
<script src="js/plugins.js"></script>
<!-- main JS
============================================ -->
<script src="js/main.js"></script>

<!-- tawk chat JS  聊天系统js
<script src="js/tawk-chat.js"></script>
============================================ -->

<script src="js/data-table/bootstrap-table.js"></script>
<script src="js/data-table/bootstrap-table-zh-CN.js"></script>

<script src="js/notifications/Lobibox.js"></script>

<script src="js/datepicker/bootstrap-datetimepicker.min.js"></script>
<script src="js/datepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="js/vue.js"></script>
<script src="customjs/eventSourcesNotify.js"></script>
</body>
<script>

    var httpHead = "http://localhost/" //nginx基础地址
    var baseGoodsHttpUrl = "http://localhost:8080/posterior_system_war_exploded/goods"; //user业务处理地址
    var baseItemHttpUrl = "http://localhost:8080/posterior_system_war_exploded/item"; //user业务处理地址
    var uploadFileUrl = "http://localhost:8080/posterior_system_war_exploded/file/upload";//上传文件地址
    /**
     * 1. 获取浏览器地址栏，然后截取路径。
     * 2. 根据路径使用jquery的选择器让其背景颜色变一下。
     */
    var url = window.location.href;   //获取浏览器地址栏 http://localhost:8081/my_cart_war_exploded/admin/index.html

    var index = url.lastIndexOf("/");  //获取最后一个 / 所在的索引的位置

    var path = '/admin' + url.substring(index);  // /admin/index.html

    $('a[href$="' + path + '"]').css('background-color', '#f7f8fb');


    //用户登出
    function logOut() {
        $.ajax({
            url: "servlet/end/login",
            method: 'get',
            dataType: "json",
            success: function (datas) {
                console.log("----datas.code----");
                console.log(datas.code);
                if (datas.code > 0) {
                    console.log("--成功--");
                    window.location.href = datas.data;
                } else {
                    showErrorBox("退出失败");
                }
            }
        })
    }


    // 显示错误提示信息
    function showErrorBox(msgText, codeState) {
        var colors = '';
        if (codeState > 0) {
            colors = 'success'
        } else {
            colors = 'warning';
        }
        Lobibox.notify(colors, {
            size: 'mini',
            delay: 2500,
            delayIndicator: false,
            position: 'center top',//定位
            title: false, //不给title
            msg: msgText,
            sound: false  // 不要音频
        })
    }


</script>
</html>
<script>
    /**
     * 1. 获取浏览器地址栏，然后截取路径。
     * 2. 根据路径使用jquery的选择器让其背景颜色变一下。
     */
    var url = window.location.href;   //获取浏览器地址栏 http://localhost:8081/my_cart_war_exploded/admin/index.html

    var index = url.lastIndexOf("/");  //获取最后一个 / 所在的索引的位置

    var path = '/admin' + url.substring(index);  // /admin/index.html

    $('a[href$="' + path + '"]').css('background-color', '#f7f8fb');


    //用户登出
    function logOut() {
        $.ajax({
            url: "servlet/end/login",
            method: 'get',
            dataType: "json",
            success: function (datas) {
                console.log("----datas.code----");
                console.log(datas.code);
                if (datas.code > 0) {
                    console.log("--成功--");
                    window.location.href = datas.data;
                } else {
                    showErrorBox("退出失败");
                }
            }
        })
    }


    // 显示错误提示信息
    function showErrorBox(msgText, codeState) {
        var colors = '';
        if (codeState > 0) {
            colors = 'success'
        } else {
            colors = 'warning';
        }
        Lobibox.notify(colors, {
            size: 'mini',
            delay: 2500,
            delayIndicator: false,
            position: 'center top',//定位
            title: false, //不给title
            msg: msgText,
            sound: false  // 不要音频
        })
    }

    /**
     * {
     *           "total": 23,
     *           "rows": [{type: '', }, {}, {}]
     *       }
     */
    $('#goodsDataTable').bootstrapTable({
        url: baseGoodsHttpUrl,
        method: 'GET',
        columns: [
            // field是返回rows中每个对象的属性名
            {title: '类型', field: 'type', align: 'center'},
            {title: '商品编号', field: 'goodsId', align: 'center'},
            {title: '描述信息', field: 'title', align: 'center', formatter: formatTitle},
            {title: '缩略图', field: 'smallPic', align: 'center', formatter: formatImg},
            {title: '价格', field: 'price', align: 'center'},
            {title: '状态', field: 'status', align: 'center', formatter: formatStatus},
            {title: '库存', field: 'stockNum', align: 'center'},
            {title: '创建日期', field: 'createTime', align: 'center'},
            {title: '更新日期', field: 'updateTime', align: 'center'},
            {title: '操作', align: 'center', formatter: addProcessBtn}
        ],
        /**
         * 决定了在哪边分页：client server, 两种不同的配置决定了服务器端返回的数据格式。
         *  client分页, 服务器端返回的数据  [{}, {}, {}]
         *  server端分页，服务器端返回的数据：{rows:[{}, {}], total: 23}
         */
        sidePagination: 'server',
        pagination: true, //表示使用分页
        toolbar: '#goodsTableToolbar'  //设置工具条
    })

    /**
     * 当内容长度大于30的时候，多余的不显示
     * @param value
     * @returns {string|*}
     */
    function formatTitle(value) {
        var length = value.length; //获取文本长度
        if (length > 30) {
            return value.substring(0, 16) + '<br/>' + value.substring(16, 31) + '...';
        }
        return value.substring(0, 16) + '<br/>' + value.substring(16);
    }

    // 格式化商品的状态
    function formatStatus(value) {
        if (value == 1) {
            return '<span class="label label-success">可用</span>'
        }
        return '<span class="label label-warning">不可用</span>'
    }

    //格式化商品图片
    function formatImg(value) {

        return '<img src = "'+httpHead + value + '" class="smallImage" onclick="showBigImg(this)">'
    }

    // 添加操作按钮
    function addProcessBtn(value, row) {
        var goodsId = row.id;
        var goodId = row.goodsId
        if (row.status == 1) {
            return '<button onclick="deleteGoods(' + goodsId + ',0)" class="btn btn-danger btn-xs">删除</button>' +
                '<button onclick="showAddGoodsModal(2,' + goodId + ')" class="btn btn-info btn-xs">编辑</button>'
        } else {
            return '<button onclick="deleteGoods(' + goodsId + ',1)" class="btn btn-success btn-xs">启用</button>' +
                '<button onclick="showAddGoodsModal(2,' + goodId + ')" class="btn btn-info btn-xs">编辑</button>'
        }

    }

    // 删除对应的商品，实际就是改状态
    function deleteGoods(goodsId, goodsStatus) {
        $.ajax({
            url: baseGoodsHttpUrl+'/info',
            data: {id: goodsId, status: goodsStatus},
            dataType: 'json',
            type: 'post',
            success: function (_data) {
                // 表示删除成功，更新表格
                if (_data.code > 0) {
                    $('#goodsDataTable').bootstrapTable('refresh');
                } else { // 删除失败，给用户一个提示
                    showErrorBox('删除失败, 请联系管理员.')
                }
            }
        })
    }

    /**
     * 展示添加的模态框
     *   1. 首先将所有种类查出来，渲染在模态框中的种类下拉列表中
     *   2. 显示模态框
     */
    function showAddGoodsModal(code, goodId) {
        //如果传入参数为1，则添加
        if (code == 1) {
            var items = $('#items');
            items.empty(); //清空种类的下拉列表
            /**
             * 第一个参数url地址
             * 第二个参数是请求的参数
             * 第三个参数是回调方法。
             */
            $.getJSON(baseItemHttpUrl, {}, function (_data) {
                for (var i = 0; i < _data.length; i++) {
                    var item = _data[i];
                    // <option value="3#shoes">鞋子</option>
                    if(i==0){
                        items.append('<option selected value="' + (item.id + '#' + item.alias) + '">' + item.name + '</option>')
                    }else {
                        items.append('<option value="' + (item.id + '#' + item.alias) + '">' + item.name + '</option>')
                    }


                }
            });
            $('#selectAddorEdit').val('add')
            $('#addGoodsModal').modal('show');
            //如果传入参数为2，则编辑
            /* <input type="hidden" id="imageServerPath">
            <input class="form-control" autocomplete="off" id="title">
            <select class="form-control" id="items">
            </select>
            <img src="../images/default.png" width="158px" id="preDisplayImage" height="180px">
            <input id="displayImage" autocomplete="off" onchange="uploadDispalyImage(this)" type="file">
            <input type="text" autocomplete="off" id="append-small-btn" placeholder="no file selected">
            <input class="form-control" autocomplete="off" id="price">
            <input class="form-control" autocomplete="off" id="stock">*/

        } else if (code == 2) {
            //回显数据
            $.ajax({
                url: baseGoodsHttpUrl+'/id/'+goodId,
                type: 'get',
                datatype: 'json',
                success: function (_data) {
                    console.log(_data)
                    /*createTime: "2020-06-08 20:33:27"
                    goodId: 1024
                    id: 25
                    imageSrc: "mobile/2256620200608.jpg"
                    price: 123
                    status: "0"
                    stock: 2
                    title: "哈哈"
                    type: "手机"
                    updateTime: "2020-06-08 20:33:27"*/
                    $('#title').val(_data.title)
                    /*$('#items').val(_data.type)*/
                    var items = $('#items');
                   items.empty(); //清空种类的下拉列表
                    $.getJSON(baseItemHttpUrl, {}, function (data) {
                        for (var i = 0; i < data.length; i++) {
                            var item = data[i];
                            // <option value="3#shoes">鞋子</option>
                            if (item.name == _data.type) {
                                items.append('<option value="' + (item.id + '#' + item.alias) + '" selected="selected">' + item.name + '</option>')
                                continue
                            }

                        }
                    });
                    $('#enGoodsId').val(_data.goodsId)
                    $('#preDisplayImage').prop('src', httpHead + _data.smallPic)
                    $('#price').val(_data.price)
                    $('#stock').val(_data.stockNum)
                    $('#imageServerPath').val(_data.smallPic)

                }
            })
            $('#selectAddorEdit').val('edit')
            $('#addGoodsModal').modal('show');
        }

    }

    // 隐藏模态框
    function destoryAddGoodsModal() {
        resetModal();
        $('#addGoodsModal').modal('hide');
    }

    //隐藏高清图
    function destoryShowBigImg() {
        //清空图片内容
        $('#bigImg').prop('src', '#');
        $('#showBigImg').modal('hide');
    }

    /**
     * 上传展示图：
     *    1.在选择图片旁边的那个输入框中显示文件的名字；
     *    2.上传图片。
     *    3.回显图片。
     */
    function uploadDispalyImage(fileTag) {
        var item = $('#items').val(); //取种类的值，目的是上传的文件放在哪个目录下

        var itemAlias = item.split('#')[1];

        var displayImage = fileTag.files[0];
        $("#displayImage").val('');
        // console.log(displayImage.name)  //文件的名字，在很多网站中要去判断文件的格式是否正确，要通过后缀来判断
        // console.log(displayImage.size); // 文件的大小，单位是字节，如果要判断多少 M, size / (1024 * 1024) 结果单位就位M
        var name = displayImage.name;

        $('#append-small-btn').val(name);

        var formData = new FormData();
        formData.append('displayImage', displayImage);
        formData.append('itemName', itemAlias);

        $.ajax({
            url: baseGoodsHttpUrl+"/headImg",
            type: 'post',
            dataType: 'json',
            data: formData,
            /**
             * 内容类型。默认值：application/x-www-form-urlencoded;
             * false表示不设置，将FormData原封不动的直接提价服务器端
             */
            contentType: false,
            /**
             * processData 处理数据， 例如get请求，会将data中的数据，name=张三&password=125,
             * 对于FormData包含文件，此处要为false, 禁止转换
             */
            processData: false,
            success: function (_data) {
                // {"filePath":"mobile/147617383170300EfssbV3XDA8PFrTsSj.jpg","imageUrl":"http://localhost/mobile/147617383170300EfssbV3XDA8PFrTsSj.jpg"}
                $('#preDisplayImage').prop('src',httpHead+ _data.urlPath);  //回显图片
                $('#imageServerPath').val(_data.urlPath);
            }
        })
    }

    // 关闭模态框的时候，重置所有的信息
    function resetModal() {
        $('#imageServerPath').val('');
        $('#items').empty();
        $('#items option').removeProp("selected");
        $('#append-small-btn').val('');
        $('#preDisplayImage').prop('src', '../images/default.png');
        $('#goodsId').val('')
        $('#title').val('');
        $('#price').val('');
        $('#stock').val('');
        $('#displayImage').val('');
    }

    // 添加商品
    function addGoods() {
        var imageServerPath = $('#imageServerPath').val();  //商品的路径
        var item = $('#items').val(); // 1#books 种类
        var itemId = item.split('#')[0]; //获取种类的id
        var price = $('#price').val();  //价格
        var stock = $('#stock').val();
        var title = $('#title').val();
        var select = $('#selectAddorEdit').val()
        var goodId = $('#goodsId').val()
        if (select == 'add') {
            // 构建请求的参数
            var requestParams = {
                smallPic: imageServerPath,
                itemId: itemId,
                price: price,
                stockNum: stock,
                title: title,
                goodsId:  $('#enGoodsId').val()
            };

            /**
             * 第一个是地址
             * 第二个是数据
             * 第三个是回调函数
             * 第四个是服务器返回的数据类型
             */
            $.post(baseGoodsHttpUrl+"/infos", requestParams, function (_data) {
                if (_data.code > 0) {
                    destoryAddGoodsModal(); //销毁添加商品模态框
                    $('#goodsDataTable').bootstrapTable('refresh');
                } else {
                    showErrorBox('添加商品失败，请联系管理员.')
                }
            }, 'json');
        } else {
            // 构建请求的参数
            var requestParams = {
                smallPic: imageServerPath,
                itemId: itemId,
                price: price,
                stock: stock,
                title: title,
                goodsId: goodId,

            };

            /**
             * 第一个是地址
             * 第二个是数据
             * 第三个是回调函数
             * 第四个是服务器返回的数据类型
             */
            $.post(baseGoodsHttpUrl+"/infos", requestParams, function (_data) {
                destoryAddGoodsModal(); //销毁添加商品模态框
                $('#goodsDataTable').bootstrapTable('refresh');
            })

        }

    }

    //商品略缩图
    function showBigImg(imgTag) {
        var imgSrc = $(imgTag).prop('src');
        $('#bigImg').prop('src', imgSrc);
        $('#showBigImg').modal('show');
    }

    /*$("img.bigImg").load(
        function(){
            $("img.smallImage").each(function(){
                var bigImageURL = $(this).attr("bigImageURL");
                img = new Image();
                img.src = bigImageURL;
                img.onload = function(){
                    console.log(bigImageURL);
                    $("div.img4load").append($(img));
                };
            });
        }
    );*/

</script>
<script src="js/my/headImgAndName.js"></script>
<script src="js/my/logOut.js"></script>